package com.headingdata.string;

import java.util.Random;

public class StringTest5 {

    public static void main(String[] args) {
        for (int i = 0; i < 50; i++) {
            Random random = new Random();
            int index = random.nextInt(4,10);
            System.out.println(index);
            String code = generateCode(index);
            System.out.println(code);
        }

    }

    public static String generateCode(int length){
        String charString = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        Random random = new Random();
        String code = new String();
        for (int i = 0; i < length; i++) {
            int index = random.nextInt(charString.length()-1);
            code += charString.charAt(index);
        }
        return code;
    }
}
